home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / Mac wt 0.04 Folder / MacWT.fat 0.04 / Mac WT source / mac_wt.h next >
Encoding:
Text File  |  1994-05-11  |  3.7 KB  |  144 lines  |  [TEXT/MMCC]

  1. //==================================================================
  2. // mac_wt.h                                            <tur 01-May-94>
  3. //
  4. //    Macintosh interface for Chris Laurel's "wt" demo.
  5. //
  6. //    Comments, Bug Reports/Fixes, etc, to turly@isltd.insignia.com
  7. //
  8. //==================================================================
  9.  
  10. #pragma once
  11.  
  12. #ifndef    macintosh
  13. #define    macintosh
  14. #endif
  15.  
  16. #ifndef    BIGEND
  17. #define    BIGEND
  18. #endif
  19.  
  20. #ifndef __TYPES__
  21. #include "Types.h"
  22. #endif
  23. #define    GotFalseTrueBoolean
  24. enum {False, True};        // Boolean is already defined in Mac's "Types.h"
  25.  
  26.  
  27. /**/
  28.  
  29. #define    PATH_MAX        80
  30.  
  31. #define    main            WTMain
  32. extern int WTMain(int argc, char **argv);        /* The "wt" main procedure */
  33.  
  34. /**/
  35.  
  36. #define    _exit(x)    fatal_error("_exit(%d) called", x)
  37.  
  38. /**/
  39.  
  40. #if    __MWERKS__
  41. #define    GOT_INLINE    1    /* MWERKS can use "inline" */
  42. #endif
  43.  
  44.  
  45. #define    HostIndexFromPCIndex(pcIndx)    (pxIndx+1)
  46. #define    HostDirFileStr                    ":wt:%s:%s"
  47. #define    HostFixupPixelData(a, b)        MacFixupPixelData(a, b)
  48.  
  49. extern void MacFixupPixelData(unsigned char *buf, int nBytes);
  50.  
  51.  
  52. /* Use inline 68K assembly for Fixed and Fract muls/divs */
  53.  
  54. #if !defined(USES68KINLINES) && (defined(THINK_C) || defined(applec))
  55.  
  56. // MPW C unfortunately gives code generation errors if we have any
  57. // of these long inline assembly routines. Bit sad, really.
  58.  
  59. #if !defined(applec)
  60. #define    USES68KINLINES    1
  61. #endif
  62. #define ONEWORDINLINE(a)        = a
  63. #endif
  64.  
  65.  
  66. #if USES68KINLINES
  67.  
  68. #pragma parameter __D0 mc68k_fixmul(__D0, __D1)
  69. extern long mc68k_fixmul(long a, long b) = {0x4C01, 0x0C01, 0x3001, 0x4840};
  70. /* mc68k_fixmul:  "muls.l d0, d1:d0", "move.w d1, d0", "swap d0" */
  71.  
  72. #pragma parameter __D0 mc68k_fixdiv(__D2, __D1)
  73. extern long mc68k_fixdiv(long num, long denom)
  74.     = {0x3002, 0x4840, 0x4240, 0x4842, 0x48C2, 0x4C41, 0x0C02};
  75. /* "move.w d2,d0", "swap d0", "clr.w d0", "swap d2", "ext.l d2", "divs.l d1, d2:d0" */
  76.  
  77. #pragma parameter __D0 mc68k_fixmul2_30(__D0, __D1)
  78. extern long mc68k_fixmul2_30(long a, long b) 
  79.     = {0x4C01, 0x0C01, 0xE589, 0xE598, 0x0280, 0x0000, 0x0003, 0x8081};
  80. /* "muls.l d1, d1:d0", "lsl.l #2, d1", "rol.l #2, d0", "and.l #3, d0", "or.l d1, d0" */
  81. /* We could probably lose the top two bits of D0 after the MULS.L without much effect,
  82. ** but I'll leave them in for the time being...
  83. */
  84.  
  85. #else    /* USES68KINLINES */
  86.  
  87. extern long mc68k_fixmul(long a, long b);
  88. extern long mc68k_fixdiv(long num, long denom);
  89. extern long mc68k_fixmul2_30(long a, long b);
  90.  
  91. #endif    /* USES68KINLINES */
  92.  
  93.  
  94. #define    PARANOID
  95.  
  96.  
  97. /* We can either use our own handcrafted fixedpoint routines (e.g., above)
  98. ** or we can use those provided in the base (which basically correspond to
  99. ** lots of floating point expressions.)
  100. **
  101. ** With Metrowerks, the floating point stuff is faster than calling the
  102. ** Mac Toolbox _FixMul, _FixDiv, etc (!) This could be because these calls
  103. ** are emulated or (more likely) the 601 likes floating point ops more than
  104. ** subroutine call/returns! Must look into this sometime.
  105. **
  106. ** For this reason, I've made the use of the Mac's 'handcrafted' routines (our
  107. ** own or _FixMul in the ROM) dependent on a define, "USE_HOST_FIXEDPOINT".
  108. **
  109. ** Currently, this will only be used if we're on a 68K box, but feel free to
  110. ** experiment!
  111. */
  112.  
  113. #if    !__powerc
  114. #define    USE_HOST_FIXEDPOINT
  115. #endif
  116.  
  117. #ifdef USE_HOST_FIXEDPOINT
  118.  
  119. #if    __powerc || applec
  120. #define     DONT_USE_ASM_FIXEDPOINT    1
  121. #endif
  122.  
  123. #if DONT_USE_ASM_FIXEDPOINT
  124. #ifndef __FIXMATH__
  125. #include <FixMath.h>
  126. #endif
  127. #ifndef __TOOLUTILS__
  128. extern pascal Fixed FixMul(Fixed a, Fixed b) ONEWORDINLINE(0xA868);
  129. #endif
  130.  
  131. #define    fixmul(a, b)        FixMul(a, b)
  132. #define    fixdiv(a, b)        FixDiv(a, b)
  133. #define    fixmul2_30(a, b)    FracMul(a, b)
  134.  
  135. #else
  136.  
  137. #define    fixmul(a, b)        mc68k_fixmul(a, b)
  138. #define    fixdiv(n, d)        mc68k_fixdiv(n, d)
  139. #define    fixmul2_30(a, b)    mc68k_fixmul2_30(a, b)
  140.  
  141. #endif
  142. #endif /* USE_HOST_FIXEDPOINT */
  143.  
  144.